package com.nulldev.util.web.nTube.pages.misc;

import com.nulldev.util.languages.json.uniapi.UniJsonValue;
import com.nulldev.util.web.HttpServer3.Response;
import com.nulldev.util.web.HttpServer3.pages.v3.HttpPage3;

public class InstancePresentCheckPage extends HttpPage3 {

	public InstancePresentCheckPage() {
		super("/api/pwa/present", true);
		super.setCachingMethod(CachingMethod.NO_CACHE);
		super.setChecks(EnhancedSecurityChecks.DISALLOW_POST_DATA, EnhancedSecurityChecks.ONLY_ALLOW_BASIC_METHODS, EnhancedSecurityChecks.POST_DATA_NO_URLS);
	}

	@SuppressWarnings("resource")
	@Override
	public Response onRequest(final Request request) {
		final UniJsonValue object = UniJsonValue.object(2);
		object.add("present", true);
		object.add("outdatedInstance", false);
		return new Response(200, object, object).setCustomMime("application/json");
	}

}
